import { Card } from 'antd'
import { render } from 'react-dom'

import Slardar from '@slardar/sdk'

import { triggerSlardar } from './event'
import { SlardarInstance } from './instance'

const useInstance = new URL(location.href).searchParams.get('useInstance')

if (!useInstance) {
  Slardar('config', {
    bid: 'cypress-test-npm',
    pid: 'main',
    domain: 'cypress.test',
    report_type: 'xhr',
    enableCatchJSErrorV2: true,
  })
}

SlardarInstance('config', {
  bid: 'cypress-test-instance',
  pid: 'main',
  domain: 'cypress.test',
  report_type: 'xhr',
  enableCatchJSErrorV2: true,
})

setTimeout(() => {
  triggerSlardar()
}, 1500)

const $root = document.querySelector('#app')
const App = () => {
  return (
    <div className="app">
      <Card>
        <h1>Slardar SDK</h1>
        <p>Testing Slardar multi instance</p>
      </Card>
    </div>
  )
}

render(<App />, $root!)
